
//校验ldap
function validateLdapDriverConfig($this, driverConfig){
	var name = $this.find("input[name='name']").val();
	var url = $this.find("input[name='url']").val();
	var base = $this.find("input[name='base']").val();
	var userDn = $this.find("input[name='userDn']").val();
	var password = $this.find("input[name='password']").val();
	var dn = $this.find("input[name='dn']").val();
	var searchScope = $this.find("select[name='searchScope'] option:checked").val();
	//校验ldap表单
	if($this.formValidate()==false){
		return null;
	}
	
	driverConfig.name = name;
	driverConfig.url = url;
	driverConfig.base = base;
	driverConfig.userDn = userDn;
	driverConfig.password = password;
	driverConfig.dn = dn;
	driverConfig.searchScope = searchScope;
	
	//组装继承对象数据
	var extsInfo = $this.find(".driverLdapObjectsContainer .input-group");
	var exts = [];
	for(var j = 0; j < extsInfo.length;j++){
		var extendObjects = $(extsInfo[j]).find("input[name='extendObjects']").val();
		exts.push(extendObjects);
	}
	driverConfig.extendObjects = exts;
	
	//读取连接信息
	var result;
	var isSuccess;
	$.ajax({  
		url : $basePath + "/driver/getLdapConnector",  
		contentType:"application/x-www-form-urlencoded",
	    type : "post",
	    data : {"json" : JSON.stringify(driverConfig)},  
	    async : false,
	    success : function(data){
	    	isSuccess = data.success;
	    	if(isSuccess){
	    		result = data.resultValue;
	    	}else{
	    		bootGrowl(data.resultValue,"danger"); 
	    	}
	    }
    });

	//如果验证成功
	if(isSuccess && result!=null){
		// 组装数据源和目标源字段
		var metaInfo = $this.find(".driverLdapParamsContainer .form-group");
		var cols = [];
		for (var i = 0; i < metaInfo.length; i++) {
			var col = $(metaInfo[i]);
			var filedName = col.find('input[name="filedName"]').val();
			var filedType = col.find('select[name="filedTypeName"]').val();
			var filedTypeName = col.find('option:selected').text();
			cols.push({
				"name" : filedName,
				"typeName" : filedTypeName,
				"type" : filedType
			});
		}
		driverConfig.column = cols;
		return driverConfig;
	}
	return null;
}